package com.yksj.healthtalk.utils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;

import com.yksj.healthtalk.comm.LodingFragmentDialog;
import com.yksj.healthtalk.comm.PayActivity;
import com.yksj.healthtalk.comm.SingleBtnFragmentDialog;
import com.yksj.healthtalk.db.ChatUserHelper;
import com.yksj.healthtalk.db.Tables.TableFriend;
import com.yksj.healthtalk.entity.CustomerInfoEntity;
import com.yksj.healthtalk.net.http.HttpRestClient;
import com.yksj.healthtalk.net.http.JsonsfHttpResponseHandler;
import com.yksj.healthtalk.net.http.ObjectHttpResponseHandler;
import com.yksj.healthtalk.net.socket.SmartFoxClient;
import com.yksj.healthtalk.ui.R;
import com.yksj.healthtalk.ui.app.AppData;
import com.yksj.healthtalk.ui.app.HTalkApplication;
import com.yksj.healthtalk.ui.chatting.ChatActivity;
import com.yksj.healthtalk.ui.doctor.DoctorCommonServiceActivity;
import com.yksj.healthtalk.ui.doctor.DoctorInterviewServiceActivity;
import com.yksj.healthtalk.ui.doctor.DoctorTimeServiceActivity;
import com.yksj.healthtalk.ui.friend.FriendHttpListener;

/**
 * 
 * @author Administrator 朋友圈网络请求
 */
public class FriendHttpUtil {
	// SOURCETYPE 0--最新 1--活跃 2--推荐 3--附近 4--同城
	// TYPE 0--找朋友 1--找医生 2--相同经历

	public static void getFriends(final CustomerInfoEntity c,final int sourceType, final FriendHttpListener mFriendHttpListener) {
		HttpRestClient.doHttpRequestSearchFriends(c, sourceType,
				new ObjectHttpResponseHandler() {
			
			@Override
					public void onSuccess(int statusCode, Object response) {
					if (response instanceof ArrayList) {
						mFriendHttpListener.responseSuccess(c.getType(),sourceType,(ArrayList<CustomerInfoEntity>) response);
					}
						super.onSuccess(statusCode, response);
					}
					@Override
					public Object onParseResponse(String content) {
						return jsonAnalysisFriendEntity(content, false);
					}
				});
	}

	public static ArrayList<CustomerInfoEntity> jsonAnalysisFriendEntity(
			String content, Boolean hasMyself) {
		ArrayList<CustomerInfoEntity> friendEntities = new ArrayList<CustomerInfoEntity>();
		try {
			JSONTokener jsonTokener = new JSONTokener(content);
			Object valueObject = jsonTokener.nextValue();
			JSONArray mJsonArray;
			if (valueObject instanceof JSONObject) {
				mJsonArray = new JSONArray();
				mJsonArray.put((JSONObject) valueObject);
			} else {
				mJsonArray = (JSONArray) valueObject;
			}
			CustomerInfoEntity mCustomerInfoEntity;
			int length=mJsonArray.length();
			friendEntities.ensureCapacity(length);
			for (int i = 0; i <length; i++) {
				JSONObject object = mJsonArray.getJSONObject(i);
				mCustomerInfoEntity = DataParseUtil.jsonToCustmerInfo(object);
				friendEntities.add(mCustomerInfoEntity);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return friendEntities;
	}

	/**
	 * 
	 * @param context
	 * @param content
	 * @param type
	 * @param sourceType
	 * @param friendType
	 *            好友类型
	 * @return
	 */
	public static ArrayList<CustomerInfoEntity> jsonAnalysisFriendEntity(
			Context context, String content, int friendType) {
		ArrayList<CustomerInfoEntity> friendEntities = new ArrayList<CustomerInfoEntity>();
		ChatUserHelper helper = ChatUserHelper.getInstance();
		AppData appData = HTalkApplication.getAppData();
		
		try {
			JSONTokener jsonTokener = new JSONTokener(content);
			Object valueObject = jsonTokener.nextValue();
			JSONArray mJsonArray;
			if (valueObject instanceof JSONObject) {
				mJsonArray = new JSONArray();
				mJsonArray.put((JSONObject) valueObject);
			} else {
				mJsonArray = (JSONArray) valueObject;
			}
			int size=mJsonArray.length();
			for (int i = 0; i < size; i++) {
				CustomerInfoEntity mCustomerInfo = DataParseUtil
						.jsonToCustmerInfo(mJsonArray.getJSONObject(i));
				if (mCustomerInfo != null) {
					friendEntities.add(mCustomerInfo);
				}
				appData.cacheInformation.put(mCustomerInfo.getId(),
						mCustomerInfo);
				if (mCustomerInfo.getIsAttentionFriend() == 1
						&& !appData.getInterestFriendIdList().contains(
								mCustomerInfo.getId())) {
					appData.getInterestFriendIdList().add(
							mCustomerInfo.getId());
				} else if (mCustomerInfo.getIsAttentionFriend() == 4
						&& !appData.getDoctorIdList().contains(
								mCustomerInfo.getId())) {
					appData.getDoctorIdList().add(mCustomerInfo.getId());
				} else if (mCustomerInfo.getIsAttentionFriend() == 3
						&& !appData.getCustomerIdList().contains(
								mCustomerInfo.getId())) {
					appData.getCustomerIdList()
							.add(mCustomerInfo.getId());
				}
				helper.saveFriendInfo(context,
						mCustomerInfo,
						SmartFoxClient.getLoginUserId(),
						mCustomerInfo.getName(), friendType);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return friendEntities;
	}

	/**
	 * 
	 * @Title: requestHttpAboutFriend
	 * @Description: 取消关注和取消黑名单的http请求
	 * @param @param group 所在组的ID
	 * @param @param child 所在子列表的ID
	 * @param @param type 0是取消关注 1是关注 2是加入黑名单 3是取消黑名单 4 收藏客户 5 是取消收藏客户 6 我的医生
	 *        7取消医生 8添加合作者
	 * @param @param returnInfo 是否返回全部资料
	 * @return void
	 * @throws
	 */
	public static void requestHttpAboutFriend(int userId,
			CustomerInfoEntity entity, int type) {
		entity.setAttentionFriendFlag(type);
		JSONObject json = new JSONObject();
		try {
			json.put("0", type);
			json.put("1", userId);
			json.put("2", entity.getId());
			json.put("3", 0);
			SmartFoxClient.sendStrRequest(SmartFoxClient.RequestCode.CODE_COLLECT_FRIEND,
					json.toString());
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 
	 * @Title: requestHttpAboutFriend
	 * @Description: 取消关注和取消黑名单的http请求
	 * @param @param group 所在组的ID
	 * @param @param child 所在子列表的ID
	 * @param @param type 0是取消关注 1是关注 2是加入黑名单 3是取消黑名单 4 收藏客户 5 是取消收藏客户
	 * @param @param returnInfo 0不返回全部资料 1 返回
	 * @return void
	 * @throws
	 */
	public static void requestHttpAboutFriend(int userId,
			CustomerInfoEntity entity, int type, int returnInfo) {
		entity.setAttentionFriendFlag(type);
		JSONObject json = new JSONObject();
		try {
			json.put("0", type);
			json.put("1", userId);
			json.put("2", entity.getId());
			json.put("3", returnInfo);
			SmartFoxClient.sendStrRequest(SmartFoxClient.RequestCode.CODE_COLLECT_FRIEND,
					json.toString());
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 关注好友
	 * 
	 * @param context
	 * @param userid
	 * @param friendid
	 * @param flag
	 *            是否是加入黑名单
	 * @param entity
	 * @param showLodingDialog 
	 * @return 0是取消关注 1是关注 2是加入黑名单 3是取消黑名单 4 收藏客户 5 是取消收藏客户 6 我的医生 7取消医生 8添加合作者
	 */
	public static CustomerInfoEntity requestAttentionTofriends(Context context,
			Boolean flag, CustomerInfoEntity entity) {
		if (flag == null) {
			flag = false;
		}
		//关系 关系 0 没有关系 1是关注的 2是黑名单 3是客户 4医生
		int isFlage=entity.getIsAttentionFriend();
		int mUserId=Integer.valueOf(SmartFoxClient.getLoginUserId());
		if (flag == false) {
			if (isFlage == 0) {
				showuploadPopWindow(context, entity);
			} else if (isFlage == 1) {
				FriendHttpUtil.requestHttpAboutFriend(mUserId,entity, 0);
			} else if (isFlage == 2) {
				DialogUtils.PromptDialogBox(context,context.getString(R.string.att_blacklist), entity);
			} else if (isFlage == 3) {
				DialogUtils.PromptDialogBox(context,context.getString(R.string.att_client), entity);
			} else if (isFlage == 4) {
				FriendHttpUtil.requestHttpAboutFriend(mUserId,entity,7);
			}else if(isFlage == 5){//取消我的合作者
				FriendHttpUtil.requestHttpAboutFriend(mUserId,entity,9);
			}
		} else {//在黑名单中
			switch (isFlage) {
			case 0:
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 2);
				break;
			case 1:
				DialogUtils.attToBlacklistDialog(context, entity);
				break;
			case 2:
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 3);
				break;
			case 3:
			case 4:
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 2);
				break;
			}
		}

		return entity;
	}

	/**
	 * 选择弹出框
	 */
	public static void showuploadPopWindow(Context context,final CustomerInfoEntity entity) {
		final int mUserId=Integer.valueOf(SmartFoxClient.getLoginUserId());
		LayoutInflater inflater = LayoutInflater.from(context);
		Button mydoctor=null; 
		Button friend=null; 
		Button cancel=null; 
		Button collaborators=null ;
		Button client=null ;
		boolean mUserIsDoctor = SmartFoxClient.getLoginUserInfo().isDoctor();
		View popView = null;
		if(mUserIsDoctor||entity.isDoctor()){
		if(mUserIsDoctor&&entity.isDoctor()){//医生加医生
			popView = inflater.inflate(R.layout.change_relation_popwindow_d_d, null);
			ViewFinder finder=new ViewFinder(popView);
			mydoctor = finder.button(R.id.my_doctor);
			friend =finder.button(R.id.my_friend);
			cancel = finder.button(R.id.cancel);
			collaborators = finder.button(R.id.my_hezuozhe);
			client =finder.button(R.id.extraadd);
			
			
		}else if(mUserIsDoctor&& !entity.isDoctor()){//医生加患者
			popView= inflater.inflate(R.layout.change_relation_popwindow_layout, null);
			ViewFinder finder=new ViewFinder(popView);
			friend =finder.button(R.id.my_friend);
			cancel =finder.button(R.id.cancel);
			client =finder.button(R.id.extraadd);
			
		}else if(entity.isDoctor()&& !mUserIsDoctor){//患者加医生
			popView= inflater.inflate(R.layout.change_relation_popwindow_d_c, null);
			ViewFinder finder=new ViewFinder(popView);
			mydoctor =finder.button(R.id.my_doctor);
			friend = finder.button(R.id.my_friend);
			cancel = finder.button(R.id.cancel);
		}
		final PopupWindow mPopupWindow = new PopupWindow(popView,LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		WheelUtils.setPopeWindow(context, popView, mPopupWindow);
		//监听器
//		我的患者
		if(client!=null)
		client.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 4);
				mPopupWindow.dismiss();
			}
		});
		
//		我的合作者
		if(collaborators!=null)
		collaborators.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 8);
				mPopupWindow.dismiss();
			}
		});
//      我的医生
	if(mydoctor!=null)
		mydoctor.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// 6 我的医生 7取消医生
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 6);
				mPopupWindow.dismiss();
			}
		});
		
//		我的病友
		if(friend!=null)
		friend.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				FriendHttpUtil.requestHttpAboutFriend(mUserId, entity, 1);
				mPopupWindow.dismiss();
			}
		});
//      取消	
		if(cancel!=null)
		cancel.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mPopupWindow.dismiss();
			}
		});
		}else{
			// 对方不是医生 不提示 直接加为我的好友
			FriendHttpUtil.requestHttpAboutFriend(mUserId,entity, 1);
		}
	}
	
	

	/**
	 * 关注 黑名单 客户 操作的 结果处理
	 * 
	 * @param context
	 * @param entity
	 * @param mAppData
	 *            0是取消关注 1是关注 2是加入黑名单 3是取消黑名单 4 收藏客户 5 是取消收藏客户
	 */
	public static void requestAttentionTofriendsResult(Context context,
			CustomerInfoEntity entity, AppData mAppData) {
		if (mAppData == null) {
			ToastUtil.showShort(context, "mAppData is null");
			return;
		}
		ToastUtil.showToastPanl("修改成功");
		// 加为医生attentionFriendFlag  1是关注 2是加入黑名单 3是取消黑名单 4 收藏客户 5 是取消收藏客户  6加医生 7取消医生 8我的合作者 9取消我的合作者
		int attentionFlag = entity.getAttentionFriendFlag();
		if (attentionFlag == 6 || attentionFlag == 7) {
			entity.setIsAttentionFriend((7 - attentionFlag) * 4);
			if (attentionFlag == 6) {
				if (!mAppData.getDoctorIdList().contains(entity.getId())) {
					mAppData.getDoctorIdList().add(entity.getId());
				}
			} else {
				if (mAppData.getDoctorIdList().contains(entity.getId())) {
					mAppData.getDoctorIdList().remove(entity.getId());
				}
			}
			return;
		}else if(attentionFlag==8){//我的合作者
			entity.setIsAttentionFriend(5);
			mAppData.addCustomer(entity);
			return ;
		}else if(attentionFlag==9){
			entity.setIsAttentionFriend(0);
			if (mAppData.getCustomerIdList().contains(entity.getId())) {
				mAppData.getCustomerIdList().remove(entity.getId());
			}
		}
		switch (attentionFlag) {
		case 0:
			entity.setIsAttentionFriend(0);
			if (mAppData.getInterestFriendIdList().contains(entity.getId())) {
				mAppData.getInterestFriendIdList().remove(entity.getId());
			}
			break;
		case 1:
			entity.setIsAttentionFriend(1);
			if (!mAppData.getInterestFriendIdList().contains(entity.getId())) {
				mAppData.getInterestFriendIdList().add(0,entity.getId());
			}
			break;
		case 2:
			// 黑名单
			entity.setIsAttentionFriend(2);
			if (mAppData.getInterestFriendIdList().contains(entity.getId())) {
			mAppData.getInterestFriendIdList().remove(entity.getId());
			}
			mAppData.blackListSize = mAppData.blackListSize + 1;
			break;
		case 3:
			entity.setIsAttentionFriend(0);
			if (mAppData.blackListSize != 0) {
				mAppData.blackListSize = mAppData.blackListSize - 1;
			}
			break;
		case 4:
			entity.setIsAttentionFriend(3);
			mAppData.addCustomer(entity);
			break;
		case 5:
			if (mAppData.getCustomerIdList().contains(
					entity.getId())) {
				mAppData.getCustomerIdList().remove(entity.getId());
			}
			entity.setIsAttentionFriend(0);
		
			break;
		}
		if (mAppData.getLatelyFriendIdList().contains(entity.getId())) {
			CollectUtils.updateFriendRecent(context, entity,entity.getId(), mAppData,
					ChatUserHelper.getInstance());
		}
		if (mAppData.getInterestFriendIdList().contains(
				entity.getId())) {
			ChatUserHelper.getInstance().saveFriendInfo(context,entity, entity.getId(),
					entity.getName(),
					TableFriend.TYPE_ATTENTION_FOR_ME);
		}
		mAppData.cacheInformation.put(entity.getId(),entity);
	}

	/**
	 * 点击聊天
	 * 
	 * @param context
	 * @param entity
	 * @param manager
	 * @param listener
	 */
	public static void onItemClick(final FragmentActivity activity,final CustomerInfoEntity entity) {
		HttpRestClient.doHttpInitChat(SmartFoxClient.getLoginUserId(),entity.getId(),new JsonsfHttpResponseHandler(activity){
			public void onSuccess(int statusCode, com.alibaba.fastjson.JSONObject response) {
				super.onSuccess(statusCode, response);
				if(!activity.isFinishing()){
					String content;
					if ((content = JsonParseUtils.filterErrorMessage(response) )!= null) {
						SingleBtnFragmentDialog.showDefault(activity.getSupportFragmentManager(),  content);
					}else {
						String sendCode = response.getString("send_code");
						Intent intent = new Intent();
						intent.setClass(activity, ChatActivity.class);
						if (!TextUtils.isEmpty(sendCode)) {
							intent.putExtra("NOTE", sendCode);
						}
						intent.putExtra(ChatActivity.KEY_PARAME, entity);
						activity.startActivity(intent);
						if (activity instanceof DoctorCommonServiceActivity || activity instanceof DoctorTimeServiceActivity || activity instanceof DoctorInterviewServiceActivity||activity instanceof PayActivity) {
							activity.finish();
						}
					}
				}
			}
		});
		

	};
	
	
	
	
	/**
	 * 点击聊天V3.2
	 * 
	 * @param context
	 * @param entity
	 * @param manager
	 * @param listener
	 * @param serviceTypeId 1为普通服务，2为预约时段服务,3为预约面访服务
	 */
//	public static void onItemClick(final Context context,String serviceTypeId,
//			final CustomerInfoEntity entity, final FragmentManager manager,
////			) {
//		// 自己不能和自己聊天
//		if (SmartFoxClient.getLoginUserId().equals(entity.getId())) {
//			SingleBtnFragmentDialog.show(manager, "提示", "你自己不能与自己互动", "知道了");
//			return;
//		}
//		HttpRestClient.doHttpEngageTheDialogue(SmartFoxClient.getLoginUserId(),
//				entity.getId(), serviceTypeId,new JsonHttpResponseHandler() {
//					private LodingFragmentDialog showLodingDialog;
//
//					@Override
//					public void onSuccess(int statusCode, JSONObject response) {
//						super.onSuccess(statusCode, response);
////						{"SERVICE_ITEM_DESC":"","witchPage":"1","roleId":"888",
////						"TickMesg":[{"SERVICE_TYPE_SUB":"按天服务（24小时）","SERVICE_PRICE":1,
////							"SERVICE_ITEM_ID":2887,"SERVICE_TYPE_SUB_ID":1}]}
//						if
//					}
//
//					@Override
//					public void onFailure(Throwable error, String content) {
//						listener.onRegisterHandler(true, entity,error.toString());
//					}
//
//					@Override
//					public void onStart() {
//						showLodingDialog = LodingFragmentDialog.showLodingDialog(manager,context.getResources());
//					}
//
//					@Override
//					public void onFinish() {
//						if (showLodingDialog !=null) {
//							showLodingDialog.dismissAllowingStateLoss();
//						}
//					}
//				});
//	};


	/**
	 * 我的医生
	 * 
	 * @param context
	 * @param object
	 *            myDoctors我关注的医生 myReceDoctors我最近联系的医生 myRegDoctors我的挂号医生
	 *            myRegHisDoctors我的历史挂号医生 "myBuyFailureDoctorsName": "支付失败医生",
	 * @param nameIndexs
	 * @param nameByIndex
	 * @param nameIndexs
	 * @param nameByIndex
	 * @param keyByIndex
	 * @return
	 */
	public static LinkedHashMap<String, ArrayList<CustomerInfoEntity>> getMyDoctors(
			Context context, JSONObject object, ArrayList<Integer> nameIndexs,
			Map<Integer, String> nameByIndex) {
		Map<Integer, String> keyByIndex = new HashMap<Integer, String>();// key
																			// 各项的Index
																			// value
																			// 惊悚数据每个列表对应的key
		// 我最近联系的医生
		if (object.has("myReceDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myReceDoctorsIndex"),
						object.getString("myReceDoctorsName"));
				keyByIndex.put(object.getInt("myReceDoctorsIndex"),
						"myReceDoctors");
				if (!nameIndexs.contains(object.getInt("myReceDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myReceDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		// 我的医生
		if (object.has("myDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myDoctorsIndex"),
						object.getString("myDoctorsName"));
				keyByIndex.put(object.getInt("myDoctorsIndex"), "myDoctors");
				if (!nameIndexs.contains(object.getInt("myDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		// 挂号医生
		if (object.has("myRegDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myRegDoctorsIndex"),
						object.getString("myRegDoctorsName"));
				keyByIndex.put(object.getInt("myRegDoctorsIndex"),
						"myRegDoctors");
				if (!nameIndexs.contains(object.getInt("myRegDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myRegDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		// 历史挂号医生
		if (object.has("myRegHisDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myRegHisDoctorsIndex"),
						object.getString("myRegHisDoctorsName"));
				keyByIndex.put(object.getInt("myRegHisDoctorsIndex"),
						"myRegHisDoctors");
				if (!nameIndexs.contains(object.getInt("myRegHisDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myRegHisDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		// 支付失败医生
		if (object.has("myBuyFailureDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myBuyFailureDoctorsIndex"),
						object.getString("myBuyFailureDoctorsName"));
				keyByIndex.put(object.getInt("myBuyFailureDoctorsIndex"),
						"myBuyFailureDoctors");
				if (!nameIndexs.contains(object
						.getInt("myBuyFailureDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myBuyFailureDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		// 超时支付
		if (object.has("myRiskChargeDoctorsName")) {
			try {
				nameByIndex.put(object.getInt("myRiskChargeDoctorsIndex"),
						object.getString("myRiskChargeDoctorsName"));
				keyByIndex.put(object.getInt("myRiskChargeDoctorsIndex"),
						"myRiskChargeDoctors");
				if (!nameIndexs.contains(object
						.getInt("myRiskChargeDoctorsIndex"))) {
					nameIndexs.add(object.getInt("myRiskChargeDoctorsIndex"));
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		Collections.sort(nameIndexs);
		LinkedHashMap<String, ArrayList<CustomerInfoEntity>> hashMap = new LinkedHashMap<String, ArrayList<CustomerInfoEntity>>();
		JSONArray array;
		try {
			for (int i = 0; i < nameIndexs.size(); i++) {
				array = object.getJSONArray(keyByIndex.get(nameIndexs.get(i)));
				hashMap.put(
						nameByIndex.get(nameIndexs.get(i)),
						FriendHttpUtil.jsonAnalysisFriendEntity(
								array.toString(), true));
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return hashMap;
	}

}
